Carbon


ThreadSwitchProcPtr

Header: Threads.h Carbon status: Supported

Defines a pointer to a thread switch callback function. Your thread switch callback function adds to the thread context information that the Thread Manager saves and restores.

typedef void(* ThreadSwitchProcPtr) (
    ThreadID threadBeingSwitched, 
    void *switchProcParam
);

You would declare your function like this if you were to name it MyThreadSwitchCallback:

void MyThreadSwitchCallback (
    ThreadID threadBeingSwitched, 
    void *switchProcParam
);
threadBeingSwitched

The thread ID of the thread whose context is being switched.

switchProcParam

A pointer to a parameter that the SetThreadSwitcher function passes to MyThreadSwitchProc.

function result

Δ

DISCUSSION

The custom switching function allows you to save and restore context information in addition to the default context information that the Thread Manager automatically saves and restores when it switches contexts. You must actually define two context-switching functions, one for leaving a thread and another for entering a thread. When leaving a thread, you call the outer context-switching function to save additional context information. When reentering a thread, you call the inner context-switching function to restore the extra information that was saved on exit.

The default context information consists of the CPU registers, the FPU registers (if any), and the location of the threadís context.

When the SetThreadSwitcher function installs the custom switching function, it automatically disables scheduling to avoid any reentrancy problems. Therefore, in the custom switching function, you should make no yield calls or other calls that would cause scheduling to occur.

AVAILABILITY

Supported in Carbon.


© 2000 Apple Computer, Inc. — (Last Updated 3/8/2000)